package com.blast.comicsisland;

import android.content.Context;
import android.os.Environment;
import android.util.Log;

import java.io.*;

/**
 * Created by ibm on 2015/6/24.
 */

/**
 * 这个类用于把assets文件夹下的漫画岛logo写入本地SDCard中，这样
 * 分享的图片路径则从SDCard中取得即可
 */
public class WriteToSD {
    public Context context;
    public WriteToSD(Context context){
        this.context = context;
    }
    public void toSDCard(){
        try {
            InputStream images = context.getResources().getAssets().open("icon.png");
            Log.d("======>",""+images);
            String path = Environment.getExternalStorageDirectory().getAbsolutePath();
            /*File file = new File(path);
            if (!file.exists()){
                file.mkdirs();
            }*/
            FileOutputStream image = new FileOutputStream(path + "/icon.png");
            byte[] arr = new byte[1024];
            int num = 0;
            while((num = images.read(arr))!=-1)
            {
                image.write(arr,0,num);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}

